< previous page page_83 next page >

Page 83
Puzzle 19
The RASDIALPARAMS Structure
The Windows remote access system is quite flexible and sophisticated. It has a large number of API functions. Unfortunately, it can be tricky to figure out which functions work under any given environment. Some aren't available under Windows 95/98. Some require later service packs on Windows NT. The RasGetEntryDialParams function can be used to retrieve information from the last successful dial-in on a specified phone book entry. It's a way to find out if the user had to change any of the phone book entries during the previous call in order to log on. There is also a function available to read phone book entries, but it doesn't work on Windows 95/98, so I'll leave it for you to research on your own.
The RasGetEntryDialParams function is defined as follows:
DWORD RasGetEntryDialParams(
    LPTSTR lpszPhonebook, // pointer to the full path and file name
                           // of the phone book file
    LPRASDIALPARAMS lprasdialparams, // pointer to a structure that
                                       // receives the connection parameters
    LPBOOL lpfPassword // indicates whether the user's password
                          // was retrieved
   );
This function is very easy to handle. The lpszPhonebook parameter will be ByVal As String, but you'll set it to vbNullString because a NULL value uses the default phone book. The lprasdialparam parameter is a pointer to a RASDIALPARAMS structure, so it will be declared by reference as the structure. The lpfPassword parameter will be a Long declared by reference and will be loaded with a flag indicating whether a stored password was retrieved into the structure. The function loads the lprasdialparams structure with any data available for the dial-in that was not in the phone book entry. The following declaration should do the trick:
Public Declare Function RasGetEntryDialParams Lib "rasapi32.dll" _
    Alias "RasGetEntryDialParamsA" ( _
    ByVal lpszPhonebook As String, _
    lprasdialparams As RASDIALPARAMS, _
    lpfPassword As Long) As Long

 
< previous page page_83 next page >